//
//  MainController.swift
//  WbHenryTest
//
//  Created by 张洪毓 on 15/11/11.
//  Copyright © 2015年 张洪毓. All rights reserved.
//

import UIKit

class MainController: UITabBarController {

    @objc func composeDidClick() {
        print(__FUNCTION__)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //自定义 tabbar
        let mainTabBar = MainTabBar()
        setValue(mainTabBar, forKey: "tabBar")
        mainTabBar.composeButton.addTarget(self, action: "composeDidClick", forControlEvents: UIControlEvents.TouchUpInside)
        
        //添加子视图控制器
        addChildViewControllers()
    }
    
    
    //添加子视图控制器函数
    func addChildViewControllers() {
        addChildViewController(HomeViewController(), title: "首页", image: "tabbar_home")
        addChildViewController(MessageViewController(), title: "消息", image: "tabbar_message_center")
        addChildViewController(DiscoverViewController(), title: "发现", image: "tabbar_discover")
        addChildViewController(ProfileViewController(), title: "我", image: "tabbar_profile")
        tabBar.tintColor = UIColor.redColor()
    }
    
    
    //重载
    private func addChildViewController(viewController: UIViewController, title: String, image: String) {
        viewController.title = title
        viewController.tabBarItem.image = UIImage(named: image)
        addChildViewController(UINavigationController(rootViewController: viewController))
    }


}
